package com.ruoyi.lxxmfx.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.lxxmfx.service.ILxxmfxService;
import com.ruoyi.lxxmfx.vo.LxxmfxVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.*;

@RestController
@RequestMapping("/sjfx/lxxmfx")
public class LxxmfxController extends BaseController {

    @Resource
    private ILxxmfxService lxxmfxService;
    @GetMapping(value = "/selectLxxmfxList")
        public AjaxResult selectLxxmfxList() {
        //return AjaxResult.success(lxxmfxService.selectLxxmfxList());
        List<LxxmfxVo> lxxmfxVos = lxxmfxService.selectLxxmfxList();

        List<String> years = new ArrayList<>();
        List<Integer> xmCounts = new ArrayList<>();
        for (LxxmfxVo lxxmfxVo : lxxmfxVos) {
            years.add(lxxmfxVo.getYear());
            xmCounts.add(lxxmfxVo.getXmCount());
        }

        //Object[] result = new Object[]{years, xmCounts};

        // 使用 Map 封装数据
        Map<String, Object> result = new HashMap<>();
        result.put("years", years);
        result.put("xmCounts", xmCounts);

        return AjaxResult.success(result);
    }

}
